﻿using WebFoundation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MHI.DeviceManager.Interfaces
{
    /// <summary>
    /// DevDeviceT,table entity: dev_device_t
    /// </summary>
    public class DevDeviceT : INotifyPropertyChanged
    {
        public static readonly string KeyId;
        public static readonly string KeyName;
        public static readonly string KeyCode;
        public static readonly string KeyDeviceType;
        public static readonly string KeyLocation;
        public static readonly string KeyLocationPoint;
        public static readonly string KeyProductionDate;
        public static readonly string KeyUseDate;
        public static readonly string KeyServiceLife;
        public static readonly string KeyProductionFactory;
        public static readonly string KeyFactoryNumber;
        public static readonly string KeyStatus;
        public static readonly string KeyTechnicalParas;
        public static readonly string KeyPrice;
        public static readonly string KeyQrCode;
        public static readonly string KeyRemark;
        public static readonly string KeyGmtCreated;
        public static readonly string KeyPersonModified;
        public static readonly string KeyGmtModified;
        public static readonly string KeyStateInfo;
        public static readonly string KeyIsUse;
        public static readonly string KeyVersion;

        static DevDeviceT()
        {
            KeyId = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Id);
            KeyName = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Name);
            KeyCode = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Code);
            KeyDeviceType = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.DeviceType);
            KeyLocation = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Location);
            KeyLocationPoint = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.LocationPoint);
            KeyProductionDate = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.ProductionDate);
            KeyUseDate = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.UseDate);
            KeyServiceLife = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.ServiceLife);
            KeyProductionFactory = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.ProductionFactory);
            KeyFactoryNumber = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.FactoryNumber);
            KeyStatus = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Status);
            KeyTechnicalParas = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.TechnicalParas);
            KeyPrice = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Price);
            KeyQrCode = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.QrCode);
            KeyRemark = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Remark);
            KeyGmtCreated = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.GmtCreated);
            KeyPersonModified = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.PersonModified);
            KeyGmtModified = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.GmtModified);
            KeyStateInfo = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.StateInfo);
            KeyIsUse = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.IsUse);
            KeyVersion = ExpressionHelper.GetPropertyName<DevDeviceT>(r => r.Version);
        }

        private int _id;
        private string _name;
        private string _code;
        private string _deviceType;
        private int _location;
        private string _locationPoint;
        private DateTime _productionDate;
        private DateTime _useDate;
        private int _serviceLife;
        private string _productionFactory;
        private string _factoryNumber;
        private int _status;
        private string _technicalParas;
        private double _price;
        private string _qrCode;
        private string _remark;
        private DateTime _gmtCreated;
        private string _personModified;
        private DateTime _gmtModified;
        private double _stateInfo;
        private int _isUse;
        private int _version;

        /// <summary>
        /// 编码 , column: id required
        /// </summary>
        [Required]
        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    NotifyOfChange(KeyId);
                }
            }
        }

        /// <summary>
        /// 名称 , column: name 
        /// </summary>
        [StringLength(30)]
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    _name = value;
                    NotifyOfChange(KeyName);
                }
            }
        }

        /// <summary>
        /// 设备编号 , column: code 
        /// </summary>
        [StringLength(20)]
        public string Code
        {
            get { return _code; }
            set
            {
                if (_code != value)
                {
                    _code = value;
                    NotifyOfChange(KeyCode);
                }
            }
        }

        /// <summary>
        /// 设备类型 电力设备、泵站、流量设备等 , column: device_type 
        /// </summary>
        [StringLength(20)]
        public string DeviceType
        {
            get { return _deviceType; }
            set
            {
                if (_deviceType != value)
                {
                    _deviceType = value;
                    NotifyOfChange(KeyDeviceType);
                }
            }
        }

        /// <summary>
        /// 安装位置 , column: location 
        /// </summary>
        [Required]
        public int Location
        {
            get { return _location; }
            set
            {
                if (_location != value)
                {
                    _location = value;
                    NotifyOfChange(KeyLocation);
                }
            }
        }

        /// <summary>
        /// 具体安装地点 , column: locationPoint 
        /// </summary>
        [StringLength(30)]
        public string LocationPoint
        {
            get { return _locationPoint; }
            set
            {
                if (_locationPoint != value)
                {
                    _locationPoint = value;
                    NotifyOfChange(KeyLocationPoint);
                }
            }
        }

        /// <summary>
        /// 生产日期 , column: production_date 
        /// </summary>
        public DateTime ProductionDate
        {
            get { return _productionDate; }
            set
            {
                if (_productionDate != value)
                {
                    _productionDate = value;
                    NotifyOfChange(KeyProductionDate);
                }
            }
        }

        /// <summary>
        /// 启用日期 , column: use_date 
        /// </summary>
        public DateTime UseDate
        {
            get { return _useDate; }
            set
            {
                if (_useDate != value)
                {
                    _useDate = value;
                    NotifyOfChange(KeyUseDate);
                }
            }
        }

        /// <summary>
        /// 使用年限 , column: service_life 
        /// </summary>
        public int ServiceLife
        {
            get { return _serviceLife; }
            set
            {
                if (_serviceLife != value)
                {
                    _serviceLife = value;
                    NotifyOfChange(KeyServiceLife);
                }
            }
        }

        /// <summary>
        /// 生产厂家 , column: production_factory 
        /// </summary>
        [StringLength(30)]
        public string ProductionFactory
        {
            get { return _productionFactory; }
            set
            {
                if (_productionFactory != value)
                {
                    _productionFactory = value;
                    NotifyOfChange(KeyProductionFactory);
                }
            }
        }

        /// <summary>
        /// 出厂编号 , column: factory_number 
        /// </summary>
        [StringLength(30)]
        public string FactoryNumber
        {
            get { return _factoryNumber; }
            set
            {
                if (_factoryNumber != value)
                {
                    _factoryNumber = value;
                    NotifyOfChange(KeyFactoryNumber);
                }
            }
        }

        /// <summary>
        /// 设备状态 @values 0 , column:  
        /// </summary>
        public int Status
        {
            get { return _status; }
            set
            {
                if (_status != value)
                {
                    _status = value;
                    NotifyOfChange(KeyStatus);
                }
            }
        }

        /// <summary>
        /// 技术参数 , column: technical_paras 
        /// </summary>
        [StringLength(100)]
        public string TechnicalParas
        {
            get { return _technicalParas; }
            set
            {
                if (_technicalParas != value)
                {
                    _technicalParas = value;
                    NotifyOfChange(KeyTechnicalParas);
                }
            }
        }

        /// <summary>
        /// 设备价格 , column: price 
        /// </summary>
        public double Price
        {
            get { return _price; }
            set
            {
                if (_price != value)
                {
                    _price = value;
                    NotifyOfChange(KeyPrice);
                }
            }
        }

        /// <summary>
        /// 设备二维码 , column: qr_code 
        /// </summary>
        [StringLength(128)]
        public string QrCode
        {
            get { return _qrCode; }
            set
            {
                if (_qrCode != value)
                {
                    _qrCode = value;
                    NotifyOfChange(KeyQrCode);
                }
            }
        }

        /// <summary>
        /// 备注 , column: remark 
        /// </summary>
        [StringLength(100)]
        public string Remark
        {
            get { return _remark; }
            set
            {
                if (_remark != value)
                {
                    _remark = value;
                    NotifyOfChange(KeyRemark);
                }
            }
        }

        /// <summary>
        /// 创建时间 , column: gmt_created 
        /// </summary>
        public DateTime GmtCreated
        {
            get { return _gmtCreated; }
            set
            {
                if (_gmtCreated != value)
                {
                    _gmtCreated = value;
                    NotifyOfChange(KeyGmtCreated);
                }
            }
        }

        /// <summary>
        /// 更新人 , column: person_modified 
        /// </summary>
        [StringLength(10)]
        public string PersonModified
        {
            get { return _personModified; }
            set
            {
                if (_personModified != value)
                {
                    _personModified = value;
                    NotifyOfChange(KeyPersonModified);
                }
            }
        }

        /// <summary>
        /// 更新时间 , column: gmt_modified 
        /// </summary>
        public DateTime GmtModified
        {
            get { return _gmtModified; }
            set
            {
                if (_gmtModified != value)
                {
                    _gmtModified = value;
                    NotifyOfChange(KeyGmtModified);
                }
            }
        }

        /// <summary>
        /// 标识状态 , column: state_info 
        /// </summary>
        public double StateInfo
        {
            get { return _stateInfo; }
            set
            {
                if (_stateInfo != value)
                {
                    _stateInfo = value;
                    NotifyOfChange(KeyStateInfo);
                }
            }
        }

        /// <summary>
        /// 是否可用 , column: is_use 
        /// </summary>
        [Required]
        public int IsUse
        {
            get { return _isUse; }
            set
            {
                if (_isUse != value)
                {
                    _isUse = value;
                    NotifyOfChange(KeyIsUse);
                }
            }
        }

        /// <summary>
        /// 版本 , column: version 
        /// </summary>
        [Required]
        public int Version
        {
            get { return _version; }
            set
            {
                if (_version != value)
                {
                    _version = value;
                    NotifyOfChange(KeyVersion);
                }
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyOfChange(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}